package server.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.oauth2.config.annotation.builders.JdbcClientDetailsServiceBuilder;
import org.springframework.security.oauth2.provider.client.BaseClientDetails;
import org.springframework.security.oauth2.provider.client.JdbcClientDetailsService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.sql.DataSource;

@RestController
@RequestMapping("/clientDetails")
public class OauthClientDetailsController {

//    @Autowired
//    private PasswordEncoder passwordEncoder;
//    @Resource
//    private DataSource dataSource;
//    @Autowired
//    private PasswordEncoder passwordEncoder;
//
//    //添加客户端
//    @RequestMapping("/add")
//    public BaseClientDetails addOauthClientDetails(String clientId, String resourceId, String scopes, String grantTypes,
//                                                   String authorities, String redirectUris, String secret){
//        String encodeSecret = passwordEncoder.encode(secret);
//        return clientDetails;
//    }

    @RequestMapping("/add")
    @PreAuthorize("hasAuthority('ROLE_USER')")
    public String add(){
        return "添加数据";
    }

    @RequestMapping("/add1")
    @PreAuthorize("hasAuthority('select')")
    public String add1(){
        return "添加数据";
    }
}
